package com.xy.config;

import com.sun.org.apache.regexp.internal.RE;
import com.xy.bean.Red;
import com.xy.dao.BookDao;
import com.xy.service.BookService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/4/8 20:00
 * @description
 */

@Configuration
@ComponentScan(basePackages = {"com.xy.service","com.xy.controller"})
public class MainConfigAutowired {

    @Primary // 默认首选
    @Bean("bookDao2")
    public BookDao bookDao() {
        BookDao bookDao = new BookDao();
        bookDao.setLable("2");
        return bookDao;
    }

    @Bean
    public Red red() {
        return new Red();
    }
}
